<template>
<view class="container">
	 <uni-nav-bar title="商品资料" left-icon="back"  fixed="true" color="#353535" backgroundColor="#fff" @clickLeft="goback"></uni-nav-bar>
  <view class="detail">
    <!--<import src="../../lib/wxParse/wxParse.wxml"></import>-->
    <!-- <jyf-parser :html="article_goodsDetail"></jyf-parser> -->
	<rich-text :nodes="article_goodsDetail|formatRichText"></rich-text>
  </view>
</view>
</template>

<script>
var app = getApp();

var util = require("../../utils/util.js");
var api = require("../../config/api.js");
import uniNavBar from "@/components/uni-nav-bar/uni-nav-bar.vue"

export default {
  data() {
    return {
      html: "",
      id: 0,
      article_goodsDetail: ""
    };
  },

  components: {uniNavBar},
  props: {},
  onLoad: function (options) {
    // 页面初始化 options为页面跳转所带来的参数
    var that = this; // console.log("html==="+JSON.stringify(options))

    console.log("html===" + options.id); // this.setData({
    //   html: JSON.parse(options.data).detailMobileHtml
    // });
    // // WxParse.wxParse('html', 'html', options.html, this);
    // WxParse.wxParse('goodsDetail', 'html', this.data.html, that);

    this.setData({
      id: options.id
    });
    this.getGoodsInfo();
  },
  methods: {
	  goback(){
		  uni.navigateBack()
	  },
    getGoodsInfo: function () {
      let that = this;
      util.request(api.GoodsDetail, {
        id: that.id
      }).then(function (res) {
        if (res.errno == 0) {
          that.setData({
            html: res.data.product.detailMobileHtml
          });
          console.log("==res.data.product.detailMobileHtml==" + res.data.product.detailMobileHtml);
          //WxParse.wxParse('goodsDetail', 'html', res.data.product.detailMobileHtml, that)
          setTimeout(() => {
            that.article_goodsDetail = res.data.product.detailMobileHtml;
          }, 200); // WxParse.wxParse('goodsDetail', 'html', res.data.product.detailMobileHtml, that);
        }
      });
    }
  },
  filters:{
  	formatRichText(rticle_goodsDetail){
  		//图片宽度全部为100%
  		 let  comment =  rticle_goodsDetail.replace(/<img/gi, '<img style="max-width:100%;height:auto;display:block" ');
  		 return comment;
  		 //图片宽度原尺寸缩小xs,但图片前后的空格无法控制
  		// let content = comment.replace(/<img[^>]*>/ig, function(match, capture) {
  		// 	//匹配图片中的width、height 进行处理替换
  		// 	match = match.replace(/(width="(.*?)")|(height="(.*?)")/ig, 
  		// 		function(getFirst, getSecond) {
  		// 			//getFirst 取出图片的width \ height 
  		// 			let numArr = getFirst.split('=');								
  		// 			let num = numArr[0] + '=' +'"' +Number(JSON.parse(numArr[1]))*xs +"px" +'"';							
  		// 			return num							
  		// 		});		
  		// 	return match;
  		// })
  		// console.log("content"+content);
  		// return content;
  	}	
  }
};
</script>
<style>
.container {
  margin-bottom: 100rpx;
}

button::after{
  border: none;
}
/deep/ .jsx-428399900{
	margin:36rpx auto 0 auto;
	width:100%;
	line-height: 50rpx;
	font-size:24rpx;
	text-indent: 2em;
	color:#88888;
	background-color:#fff;
}
.goodsimgs {
  width: 100%;
  height: 990rpx;
}

.goodsimgs image {
  width: 100%;
  height: 100%;
}

.service-policy {
  width: 100%;
  height: 73rpx;
  background: #f4f4f4;
  padding: 0 31.25rpx;
  display: flex;
  flex-flow: row nowrap;
  align-items: center;
  justify-content: space-between;
}

.service-policy .item {
  background: url("http://nos.netease.com/mailpub/hxm/yanxuan-wap/p/20150730/style/img/icon-normal/servicePolicyRed-518d32d74b.png") 0 center no-repeat;
  background-size: 10rpx;
  padding-left: 15rpx;
  display: flex;
  align-items: center;
  font-size: 25rpx;
  color: #666;
}

.goods-info {
  width: 750rpx;
  height: auto;
  background: #fff;
  display: flex;
  flex-direction: row;
  align-items: center;
}

.goods-info .l {
  display: block;
  width: 718.75rpx;
  height: 100%;
  margin-left: 31.25rpx;
  padding: 38rpx 31.25rpx 38rpx 0;
  flex: 1;
}

.goods-info .r {
  display: flex;
  width: auto;
  height: 100%;
  margin-right: 15rpx;
}

.goods-info .r .item {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 15rpx;
}

.goods-info .icon {
  display: block;
  width: 30rpx;
  height: 30rpx;
}

.goods-info .r .txt {
  margin-top: 12rpx;
  font-size: 26rpx;
  color: #888888;
}

.goods-info .l text {
  display: block;
  width: 100%;
  text-align: left;
  color: #333333;
}

.goods-info .name {
  height: auto;
  /* margin-bottom: 5.208rpx; */
  font-size: 36rpx;
  overflow: hidden;
  /* line-height: 41rpx; */
}

.goods-info .desc {
  height: 43rpx;
  margin-bottom: 41rpx;
  font-size: 24rpx;
  line-height: 36rpx;
  color: #999;
}

.goods-info .price {
  height: 35rpx;
  font-size: 35rpx;
  line-height: 35rpx;
  color: #b4282d;
}

.goods-info .brand {
  margin-top: 23rpx;
  min-height: 40rpx;
  text-align: center;
}

.goods-info .brand text {
  display: inline-block;
  width: auto;
  padding: 2px 30rpx 2px 10.5rpx;
  line-height: 35.5rpx;
  border: 1px solid #f48f18;
  font-size: 25rpx;
  color: #f48f18;
  border-radius: 4px;
  background: url("http://nos.netease.com/mailpub/hxm/yanxuan-wap/p/20150730/style/img/icon-normal/detailTagArrow-18bee52dab.png") 95% center no-repeat;
  background-size: 10.75rpx 18.75rpx;
}

.section-nav {
  width: 750rpx;
  height: 108rpx;
  background: #fff;
  margin-bottom: 20rpx;
}

.section-nav .t {
  float: left;
  width: 600rpx;
  height: 108rpx;
  line-height: 108rpx;
  font-size: 29rpx;
  color: #333;
  margin-left: 31.25rpx;
}

.section-nav .i {
  float: right;
  width: 52rpx;
  height: 52rpx;
  margin-right: 16rpx;
  margin-top: 28rpx;
}

.section-act .t {
  float: left;
  display: flex;
  align-items: center;
  width: 600rpx;
  height: 108rpx;
  overflow: hidden;
  line-height: 108rpx;
  font-size: 29rpx;
  color: #999;
  margin-left: 31.25rpx;
}

.section-act .label {
  color: #999;
}

.section-act .tag {
  display: flex;
  align-items: center;
  padding: 0 10rpx;
  border-radius: 3px;
  height: 37rpx;
  width: auto;
  color: #f48f18;
  overflow: hidden;
  border: 1px solid #f48f18;
  font-size: 25rpx;
  margin: 0 10rpx;
}

.section-act .text {
  display: flex;
  align-items: center;
  height: 37rpx;
  width: auto;
  overflow: hidden;
  color: #f48f18;
  font-size: 29rpx;
}

.comments {
  width: 100%;
  height: auto;
  padding-left: 30rpx;
  background: #fff;
  margin: 20rpx 0;
}

.comments .h {
  height: 102.5rpx;
  line-height: 100.5rpx;
  width: 718.75rpx;
  padding-right: 16rpx;
  border-bottom: 1px solid #d9d9d9;
}

.comments .h .t {
  display: block;
  float: left;
  width: 50%;
  font-size: 38.5rpx;
  color: #333;
}

.comments .h .i {
  display: block;
  float: right;
  width: 164rpx;
  height: 100.5rpx;
  line-height: 100.5rpx;
  background: url("http://nos.netease.com/mailpub/hxm/yanxuan-wap/p/20150730/style/img/icon-normal/address-right-990628faa7.png") right center no-repeat;
  background-size: 52rpx;
}

.comments .b {
  height: auto;
  width: 720rpx;
}

.comments .item {
  height: auto;
  width: 720rpx;
  overflow: hidden;
}

.comments .info {
  height: 127rpx;
  width: 100%;
  padding: 33rpx 0 27rpx 0;
}

.comments .user {
  float: left;
  width: auto;
  height: 67rpx;
  line-height: 67rpx;
  font-size: 0;
}

.comments .user image {
  float: left;
  width: 67rpx;
  height: 67rpx;
  margin-right: 17rpx;
  border-radius: 50%;
}

.comments .user text {
  display: inline-block;
  width: auto;
  height: 66rpx;
  overflow: hidden;
  font-size: 29rpx;
  line-height: 66rpx;
}

.comments .time {
  display: block;
  float: right;
  width: auto;
  height: 67rpx;
  line-height: 67rpx;
  color: #7f7f7f;
  font-size: 25rpx;
  margin-right: 30rpx;
}

.comments .content {
  width: 720rpx;
  padding-right: 30rpx;
  line-height: 45.8rpx;
  font-size: 29rpx;
  margin-bottom: 24rpx;
}

.comments .imgs {
  width: 720rpx;
  height: auto;
  margin-bottom: 25rpx;
}

.comments .imgs .img {
  height: 150rpx;
  width: 150rpx;
  margin-right: 28rpx;
}

.comments .spec {
  width: 720rpx;
  padding-right: 30rpx;
  line-height: 30rpx;
  font-size: 24rpx;
  color: #999;
  margin-bottom: 30rpx;
}

.goods-attr {
  width: 750rpx;
  height: auto;
  overflow: hidden;
  padding: 0 31.25rpx 25rpx 31.25rpx;
  background: #fff;
}

.goods-attr .t {
  width: 687.5rpx;
  height: 104rpx;
  line-height: 104rpx;
  font-size: 38.5rpx;
}

.goods-attr .item {
  width: 687.5rpx;
  height: 68rpx;
  padding: 11rpx 20rpx;
  margin-bottom: 11rpx;
  background: #f7f7f7;
  font-size: 38.5rpx;
}

.goods-attr .left {
  float: left;
  font-size: 25rpx;
  width: 134rpx;
  height: 45rpx;
  line-height: 45rpx;
  overflow: hidden;
  color: #999;
}

.goods-attr .right {
  float: left;
  font-size: 36.5rpx;
  margin-left: 20rpx;
  width: 480rpx;
  height: 45rpx;
  line-height: 45rpx;
  overflow: hidden;
  color: #333;
}

.detail {
  width: 750rpx;
  height: auto;
  overflow: hidden;
  margin-top: 20rpx;
  margin-bottom: 20rpx;
}

.detail image {
  width: 750rpx;
  display: block;
}

.common-problem {
  width: 750rpx;
  height: auto;
  overflow: hidden;
}

.common-problem .h {
  position: relative;
  height: 145.5rpx;
  width: 750rpx;
  padding: 56.25rpx 0;
  background: #fff;
  text-align: center;
}

.common-problem .h .line {
  display: inline-block;
  position: absolute;
  top: 72rpx;
  left: 0;
  z-index: 2;
  height: 1px;
  margin-left: 225rpx;
  width: 300rpx;
  background: #ccc;
}

.common-problem .h .title {
  display: inline-block;
  position: absolute;
  top: 56.125rpx;
  left: 0;
  z-index: 3;
  height: 33rpx;
  margin-left: 285rpx;
  width: 180rpx;
  background: #fff;
}

.common-problem .b {
  width: 750rpx;
  height: auto;
  overflow: hidden;
  padding: 0rpx 30rpx;
  background: #fff;
}

.common-problem .item {
  height: auto;
  overflow: hidden;
  padding-bottom: 25rpx;
}

.common-problem .question-box .spot {
  float: left;
  display: block;
  height: 8rpx;
  width: 8rpx;
  background: #b4282d;
  border-radius: 50%;
  margin-top: 11rpx;
}

.common-problem .question-box .question {
  float: left;
  line-height: 30rpx;
  padding-left: 8rpx;
  display: block;
  font-size: 26rpx;
  padding-bottom: 15rpx;
  color: #303030;
}

.common-problem .answer {
  line-height: 36rpx;
  padding-left: 16rpx;
  font-size: 26rpx;
  color: #787878;
}

.related-goods {
  width: 750rpx;
  height: auto;
  overflow: hidden;
}

.related-goods .h {
  position: relative;
  height: 145.5rpx;
  width: 750rpx;
  padding: 56.25rpx 0;
  background: #fff;
  text-align: center;
  border-bottom: 1px solid #f4f4f4;
}

.related-goods .h .line {
  display: inline-block;
  position: absolute;
  top: 72rpx;
  left: 0;
  z-index: 2;
  height: 1px;
  margin-left: 225rpx;
  width: 300rpx;
  background: #ccc;
}

.related-goods .h .title {
  display: inline-block;
  position: absolute;
  top: 56.125rpx;
  left: 0;
  z-index: 3;
  height: 33rpx;
  margin-left: 285rpx;
  width: 180rpx;
  background: #fff;
}

.related-goods .b {
  width: 750rpx;
  height: auto;
  overflow: hidden;
}

.related-goods .b .item {
  float: left;
  background: #fff;
  width: 375rpx;
  height: auto;
  overflow: hidden;
  text-align: center;
  padding: 15rpx 31.25rpx;
  border-right: 1px solid #f4f4f4;
  border-bottom: 1px solid #f4f4f4;
}

.related-goods .item .img {
  width: 311.45rpx;
  height: 311.45rpx;
}

.related-goods .item .name {
  display: block;
  width: 311.45rpx;
  height: 35rpx;
  margin: 11.5rpx 0 15rpx 0;
  text-align: center;
  overflow: hidden;
  font-size: 30rpx;
  color: #333;
}

.related-goods .item .price {
  display: block;
  width: 311.45rpx;
  height: 30rpx;
  text-align: center;
  font-size: 30rpx;
  color: #b4282d;
}

.bottom-btn {
  position: fixed;
  /* left: 0; */
  bottom: 0;
  z-index: 10;
  width: 750rpx;
  height: 100rpx;
  display: flex;
  background: #fff;
  align-items: center;
  box-shadow: 0rpx 10rpx 50rpx 10rpx rgba(85, 85, 85, 0.10);
}

.bottom-btn .l {
  /* float: left; */
  height: 100rpx;
  /* width: auto; */
  /* border: 1px solid #f4f4f4; */
  display: flex;
  align-items: center;
  /* justify-content: center; */
  margin-left: 30rpx;
  margin-right: 15rpx;
}
.bottom-btn .l .action {
  /* position: relative;
  height: 60rpx;
  width: 60rpx;
  margin-left: 30rpx;
  margin-right: 15rpx; */
  flex: 1;
}
.bottom-btn .l .kefu {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0;
  background: #fff;
}

.bottom-btn .txt {
  display: block;
  font-size: 20rpx;
  text-align: center;
  margin: 10rpx auto;
  line-height: 1;
  color: #333;
}

.bottom-btn .l.l-collect {
  border-right: none;
  border-left: none;
  text-align: center;
}

.bottom-btn .l.action .box {
  position: relative;
  height: 45rpx;
  width: 50rpx;
  margin-left: 10rpx;
  margin-top: -8rpx;
}

.bottom-btn .l.action .cart-count {
  height: 28rpx;
  width: 28rpx;
  z-index: 10;
  position: absolute;
  top: 0;
  right: 0;
  background: #b4282d;
  text-align: center;
  font-size: 18rpx;
  color: #fff;
  line-height: 28rpx;
  border-radius: 50%;
}

.bottom-btn .l.action .icon {
  position: absolute;
  top: 10rpx;
  left: 0;
}

.bottom-btn .l .icon {
  display: block;
  height: 30rpx;
  width: 30rpx;
  margin: 0 auto;
}

.bottom-btn .c {
  float: left;
  height: 100rpx;
  line-height: 96rpx;
  flex: 1;
  text-align: center;
  color: #fff;
  /* border-top: 1px solid #f4f4f4;
  border-bottom: 1px solid #f4f4f4; */
  background: #353535;
  font-size: 30rpx;
  margin-left: 35rpx;
}

.bottom-btn .r {
  /* border: 1px solid #b4282d; */
  background: #b28850;
  float: left;
  height: 100rpx;
  line-height: 96rpx;
  flex: 1;
  text-align: center;
  color: #fff;
  font-size: 30rpx;
  display: flex;
  flex-direction: column;
}

.share-bar {
  width: 100%;
  height: auto;
  position: fixed;
  background-color: #f1f1f1;
  z-index: 11;
  bottom: 0;
  /* display: none; */
  display: flex;
  flex-direction: column;
  border-radius: 15rpx 15rpx 0 0;
}
.share-bar .bars {
  width: 100%;
  height: auto;
  display: flex;
  padding: 40rpx 20rpx 0 0;
  background-color: #fff;
}
.share-bar .bars .item {
  width: auto;
  height: 160rpx;
  display: flex;
  flex-direction: column;
  flex: 1;
  align-items: center;
  padding: 0;
  background-color: #fff;
  border: none;
}
.share-bar .bars .item .icon {
  width: 80rpx;
  height: 80rpx;
}
.share-bar .bars .item .txt {
  width: 130rpx;
  height: auto;
  font-size: 26rpx;
  color: #353535;
}
.share-bar .bottom{
  width: 100%;
  height: 100rpx;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: #fff;
  margin-top: 20rpx;
}
.share-bar .bottom .txt{
  font-size: 30rpx;
  color: #333333;
}



.attr-pop-box {
  width: 100%;
  height: 100%;
  position: fixed;
  background: rgba(0, 0, 0, .5);
  z-index: 8;
  bottom: 0;
  /* display: none; */
}

.attr-pop {
  width: 100%;
  height: auto;
  max-height: 780rpx;
  padding: 30rpx 0 30rpx 30rpx;
  background: #fff;
  position: fixed;
  z-index: 9;
  bottom: 100rpx;
  border-top-left-radius: 12rpx;
  border-top-right-radius: 12rpx;
  overflow: hidden;
}

.attr-pop .close {
  position: absolute;
  width: 48rpx;
  height: 48rpx;
  right: 31.25rpx;
  overflow: hidden;
  top: 40rpx;
}

.attr-pop .close .icon {
  width: 48rpx;
  height: 48rpx;
}

.attr-pop .img-info {
  width: 687.5rpx;
  height: auto;
  overflow: hidden;
  margin-bottom: 41.5rpx;
}

.attr-pop .img {
  float: left;
  height: 177rpx;
  width: 177rpx;
  background: #f4f4f4;
  margin-right: 31.25rpx;
  border-radius: 12rpx;
}

.attr-pop .info {
  float: left;
  height: auto;
  display: flex;
  align-items: center;
}

.attr-pop .n {
  font-size: 28rpx;
  color: #353535;
  height: auto;
  line-height: 33rpx;
  margin-bottom: 10rpx;
  width: 430rpx;
  overflow: hidden;
}

.attr-pop .p {
  display: flex;
  flex-direction: row;
  align-items: center;
  color: #d73d2e;
  height: auto;
  /* line-height: 33rpx; */
  margin-bottom: 10rpx;
  margin-top: 10rpx;
}

.attr-pop .p1 {
  font-size: 24rpx;
}

.attr-pop .p2 {
  font-size: 36rpx;
}
.attr-pop .c {
  overflow: hidden;
}

.attr-pop .a {
  font-size: 29rpx;
  color: #333;
  height: 40rpx;
  line-height: 40rpx;
}

.spec-con {
  width: 100%;
  height: auto;
  overflow: hidden;
  
}

.spec-con .spec-item {
  margin-top: 24rpx;
}

.spec-con .name {
  margin-bottom: 22rpx;
  font-size: 30rpx;
  color: #353535;
  width: 150rpx;
}

.spec-con .values {
  height: auto;
  margin-bottom: 30rpx;
  font-size: 0;
}

.spec-con .value {
  display: inline-block;
  height: 62rpx;
  padding: 0 20rpx;
  line-height: 60rpx;
  text-align: center;
  margin-right: 20rpx;
  margin-bottom: 30rpx;
  /* border: 1px solid #353535; */
  font-size: 26rpx;
  color: #353535;
  background-color: #eaeaea;
  border-radius: 4rpx;
}

.spec-con .value.disable {
  border: 1px solid #ccc;
  color: #ccc;
}

.spec-con .value.selected {
  /* border: 1px solid #eaeaea; */
  color: #ffffff;
  background-color: #b28850;
  border-radius: 4rpx;
}
.spec-con .number-item {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  margin: 30rpx 0;
  padding-right: 30rpx;
}
.number-item .selnum {
  width: auto;
  height: 71rpx;
  border: 1px solid #e5e4e5;
  display: flex;
}

.number-item .name {
  font-size: 30rpx;
  color: #353535;
  margin-bottom: 0rpx;
}

.number-item .cut {
  width: 60rpx;
  height: 100%;
  text-align: center;
  line-height: 60rpx;
  color: #888888;
  background-color: #ffffff;
}

.number-item .cut.noChange {
  width: 60rpx;
  height: 100%;
  text-align: center;
  line-height: 60rpx;
  color: #888888;
  background-color: #f1f1f1;
}

.number-item .number {
  flex: 1;
  height: 100%;
  text-align: center;
  line-height: 60rpx;
  border-left: 1px solid #e5e4e5;
  border-right: 1px solid #e5e4e5;
  width: 80rpx;
  font-size: 26rpx;
}

.number-item .add {
  width: 60rpx;
  height: 100%;
  text-align: center;
  line-height: 60rpx;
  color: #888888;
  background-color: #ffffff;
}

.divLine{
  background: #e5e4e5;
  width: 100%;
  height: 2rpx;
  margin-right: -30rpx;
 }

</style>